import 'package:flutter/material.dart';
import 'package:flutter_module/page/hi_native_page.dart';
import 'package:flutter_module/page/recommend_page.dart';

import 'page/favorite_page.dart';

//至少要有一个主入口
void main() => runApp(MyApp(FavoritePage()));

@pragma('vm:entry-point') //注册多个入口
void recommend() => runApp(MyApp(RecommendPage()));

@pragma('vm:entry-point') //注册多个入口 nativeView 对应Native FavoriteFragment 中传递的
void nativeView() => runApp(MyApp(HiNativePage()));

//耗时任务建议放在 initState中 不要放在build方法中

class MyApp extends StatelessWidget {
  final Widget page;

  const MyApp(this.page);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Android 架构师',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or press Run > Flutter Hot Reload in a Flutter IDE). Notice that the
        // counter didn't reset back to zero; the application is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: page,
      ),
    );
  }
}
